#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,W,L,V,d[N],v[N],a[N],p[N],cnt;
void solve(){
	cnt=0;
	cin>>n>>m>>L>>V;
	for(int i=1;i<=n;i++){cin>>d[i]>>v[i]>>a[i];}
	for(int i=1;i<=m;i++){cin>>p[i];}
	for(int i=1;i<=n;i++){
		if(a[i]<0){
			if(v[i]<V){
				continue;
			}
			int ft=lower_bound(p+1,p+m+1,d[i])-p;
			int fd=p[ft]-a[i];
			int k=ft;
			if(ft-a[i]*2+v[i]*v[i]-V*V){
				cnt++;
			}
			

			else if(a[i]=0){
				if(v[i]<=V)
					continue;
				cnt++;
			}
			else if(a[i]>0){
				if(v[i]>V){
					cnt++;
					continue;
				}
			}
			int lt=p[m]-d[i];
			if(lt*a[i]*2+v[i]*v[i]>V*V)
				cnt++;
		}
	}
	cout<<cnt<<" "<<m-1<<"\n";
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>W;
	while(W--){
		solve();
	}
	return 0;
}